﻿/*!
* Ext Gantt 1.1->1.2 Compatibility layer
* Copyright(c) 2009-2011 Mats Bryntse Consulting
* mats@ext-scheduler.com
* http://www.ext-scheduler.com/license.html
*
*/

Ext.reg('treegantt', Sch.gantt.GanttPanel);

Sch.TreeGanttPanel = Sch.gantt.GanttPanel;
Sch.DependencyDragDrop = Sch.gantt.DependencyDragDrop;
Sch.DependencyManager = Sch.gantt.DependencyManager;

Sch.ViewBehaviour = {
    HourView : Ext.emptyFn,
    DayView : Ext.emptyFn,
    WeekView : Ext.emptyFn,
    MonthView : Ext.emptyFn,
    YearView : Ext.emptyFn
};

Sch.ColumnFactory.defaults = { width : null };

Ext.override(Sch.gantt.GanttPanel, {
    
    initComponent : Sch.gantt.GanttPanel.prototype.initComponent.createInterceptor(function(cfg) {
        
        if (this.initialConfig.store) {
            console.warn('You should now specify taskStore instead of store');
        }
        
        if (this.initialConfig.viewModel) {
            var vm = this.initialConfig.viewModel;
            this.eventRenderer = vm.renderer || this.eventRenderer;
            this.startDate = vm.start;
            this.endDate = vm.end || this.endDate;
            console.warn('You should no longer use viewModel to configure the gantt chart, it instead accepts startDate, endDate, eventRenderer and viewPreset (similar to columnType)');
        }
    }),

    setView : function(startDate, endDate, columnType, viewBehaviour, renderer, timeColumnDefaults) {
        console.warn('SetView is deprecated, use SwitchViewPreset or setTimeSpan');
        if (!columnType) {
            this.setTimeSpan(startDate, endDate);
        } else {

            if (!Sch.PresetManager.getPreset(columnType)) {
                console.warn(columnType + ' is not a valid preset. You can find the built in presets in sch.gantt.viewpresets.js, and you can of course easily create your own as seen in some of the examples.');

                columnType = 'dayAndWeek';
            }

            this.switchViewPreset(columnType, startDate, endDate);
        }
    }
});
